<?php
	namespace Common\Logic;
	use Common\Model\UserVideoModel;
	class UserVideoLogic extends UserVideoModel{
		/*
		* Function:		getUserVideoList
		* Description:	用户视频列表
		* @param:		$page string 起始页
						$filter array 过滤数组
						$pageSize string 每页显示条数
		*/
		public function getUserVideoList($page=1,$filter = '',$pageSize=20){
			$conditon = $this->getUserVideoFilter($filter);
			return $this->where($conditon)->order('id desc')->limit(($page-1)*$pageSize,$pageSize)->select();
		}
		
		/*
		* Function:get:	getUserVideoFilter
		* Description:	用户视频列表搜索过滤项
		* @param:		$filter array 过滤数组
		*/
		public function getUserVideoFilter($filter = ''){
			$conditon = array();
			$conditon['status'] = 1;
			if(!empty($filter['user_id'])){
				$conditon['user_id'] = $filter['user_id'];
			}
			return $conditon;
		}
		
		/*
		* Function:get:	getUserVideoCount
		* Description:	用户视频列表总数
		* @param:		$filter array 过滤数组
		*/
		public function getUserVideoCount($filter = ''){
			$conditon = $this->getUserVideoFilter($filter);
			return $this->where($conditon)->count();
		}
		
		/*
		* Function:		addUserVideo
		* Description:	增加用户视频
		* @param:		$data array 增加的数组
		*/
		public function addUserVideo($data){
			return $this->add($data);
		}
		
		/*
		* Function:		getUserVideoInfo
		* Description:	获取用户视频信息 by row
		* @param:		$id int ID
		*/
		public function getUserVideoInfo($id){
			return $this->where(array('id'=>$id))->find();
		}
		
		/*
		* Function:		updateUserVideo
		* Description:	更新用户视频
		* @param:		$data array 更新的数组
		*/
		public function updateUserVideo($data){
			return $this->save($data);
		}
		
		/*
		* Function:		deleteUserVideo
		* Description:	删除用户视频
		* @param:		$id int ID
		*/
		public function deleteUserVideo($id){
			return $this->where(array('id'=>$id))->delete();
		}
	}
?>